package site.luojie.sss.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import site.luojie.sss.pojo.Resume;
import site.luojie.sss.repository.ResumeRepository;
import site.luojie.sss.service.ResumeService;

import java.util.List;
import java.util.Optional;

/**
 * @Description:
 * @Author jie.luo
 * @Create: 2020-05-19 23:11
 **/
@Service
@Transactional(rollbackFor = Exception.class)
public class ResumeServiceImpl implements ResumeService {

    @Autowired
    private ResumeRepository resumeRepository;

    @Override
    public List<Resume> findAll() {
        return resumeRepository.findAll();
    }

    @Override
    public Resume findById(Long id) {
        Optional<Resume> byId = resumeRepository.findById(id);
        if (byId.isPresent()) {
            return byId.get();
        }
        return null;
    }

    @Override
    public void saveResume(Resume resume) {
        resumeRepository.save(resume);
    }

    @Override
    public void deleteResumeById(Long id) {
        resumeRepository.deleteById(id);
    }
}
